﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace YYAPI
{
    public class Log
    {
        #region 写入日志文件
        /// <summary>
        /// 写入日志文件
        /// </summary>
        /// <param name="strText">日志文本</param>
        public string LogWrite(string strMenuFilePath, string strText)
        {
            FileStream fs = null;
            StreamWriter sw = null;
            try
            {
                fs = new FileStream(strMenuFilePath, FileMode.Append, FileAccess.Write);
                sw = new StreamWriter(fs, Encoding.GetEncoding("utf-8"));
                sw.Write(DateTime.Now.ToString("HH:mm:ss") + "：" + strText + "\r\n");
                sw.Flush();
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
            finally
            {
                if (sw != null)
                    sw.Close();
                if (fs != null)
                    fs.Close();
            }
            return "";
        }
        #endregion
    }
}
